function plotChar(filename)
    if nargin < 1, filename = 'spt_samp'; end

    fid = fopen(filename, 'r', 'n', 'GBK');
    h = figure; hold on; set(h, 'Visible', 'On');
    xlabel('x'), ylabel('y')
    set(gca, 'xaxislocation', 'top', 'yaxislocation', 'left', 'ydir', 'reverse')
    axis equal
    %axis image off
    
    style = 'ymcrgbk';
    i = 0;
    while ~feof(fid) 
        s = fgetl(fid); % read single line as string
        [x, y, sCharIdx] = getPoints(s);
        if ~isempty(x)
            type = style(mod(sCharIdx,7)+1);
            plot(x, y, type);
        end
    end
    fclose(fid);
    
    %saveas(h, 'spt_samp.png');
    %imtool('spt_samp.png')
end

function [x, y, sCharIdx] = getPoints(str)
    x = []; y = []; sCharIdx = [];

    p = strfind(str, 'sCharIdx');
    if isempty(p), return;
    else str = str(p(1) + 8:end); end
    
    p = strfind(str, 'nPtNum');
    if isempty(p)
        return;
    else
        sCharIdx = sscanf(str, '%d');
        str = str(p(1) + 6:end);
    end
    
    p = strfind(str, '(');
    if isempty(p), return;
    else str = str(p(1):end); end
    
    str = replace(str, '(', ' ');
    str = replace(str, ')', ' ');
    str = replace(str, ',', ' ');
    
    n = sscanf(str, '%d');
    x = n(1:2:end); y = n(2:2:end);
end
